package com.guigu.basedservice.controller;


import com.github.pagehelper.PageInfo;
import com.guigu.basedservice.entity.BaseCarType;
import com.guigu.basedservice.service.BaseCarTypeService;
import com.guigu.basedservice.vo.BaseCarTypeVo;
import com.guigu.commonutils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * <p>
 * 车型 前端控制器
 * </p>
 *
 * @author Heyuhang
 * @since 2024-09-13
 */
@CrossOrigin
@Api(description = "BaseCarType请求控制类")
@RestController
@RequestMapping("/basedservice/base-car-type")
public class BaseCarTypeController {

    @Autowired
    private BaseCarTypeService baseCarTypeService;

    @ApiOperation("查询所有BaseCarBrand分页数据")
    @RequestMapping("/show/{currentPage}/{pageSize}")
    public R show(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody BaseCarTypeVo vo
    ){
        System.out.println("hao"+vo);
        PageInfo<BaseCarType> baseCarTypePageInfo = baseCarTypeService.show(vo,currentPage, pageSize);
        return R.ok().data("baseCarTypePageInfo", baseCarTypePageInfo);
    }

    @RequestMapping("/getOne/{id}")
    public BaseCarType getOne(@PathVariable String id){
        return baseCarTypeService.getById(id);
    }

    @RequestMapping("/add2")
    public Integer add2(@RequestBody BaseCarType baseCarType){
        System.out.println("baseCarType++++"+baseCarType);
        baseCarType.setVersion(BigDecimal.valueOf(0));
        int i = baseCarTypeService.add2(baseCarType);
        return i;
    }

    @RequestMapping("/update2")
    public Boolean update2(@RequestBody BaseCarType baseCarType){
        return baseCarTypeService.updateById(baseCarType);
    }

    @RequestMapping("/delete/{carTypeUuid}")
    public Boolean delete(@PathVariable String carTypeUuid){
        return baseCarTypeService.removeById(carTypeUuid);
    }

}

